#define  _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int arr[100][100] = { 0 };
int main()
{
    int row = 0, col = 0;
    while (scanf("%d %d", &row, &col) != EOF)
    {
        int i = 0, j = 0, sum = 0, x = 0, y = 0;
        for (i = 0; i < row; i++)
        {
            sum = 0;
            x = i;
            y = 0;
            for (j = 0; j < col; j++)
            {
                scanf("%d", &arr[i][j]);
                if (arr[i][j] > arr[x][y])
                {
                    x = i;
                    y = j;
                }
                sum += arr[i][j];
            }
            arr[x][y] = sum;
        }
        for (i = 0; i < row; i++)
        {
            for (j = 0; j < col; j++)
                printf("%d ", arr[i][j]);
            printf("\n");
        }
    }

    return 0;
}